package com.ifamily.utils;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/spring/*.xml"})
@TransactionConfiguration(defaultRollback=true)
public class ExportDatabaseSchema {

 
  @Test
  public void exportDatabaseSchema(){

    Configuration configuration = new AnnotationConfiguration();
    configuration.addPackage("com.ifamily.domain.user");

    SchemaExport schema = new SchemaExport(configuration);
    schema.setOutputFile("resources/sql/schema.sql");
    schema.create(false, false);
  }
}

